
#pragma once
#pragma comment( lib, "WS2_32.lib" )

#include <winsock2.h>
#include "sockexcept.h"
#include "pattern/singleton.h"

namespace sock {

	class WsaRoutine : public Singleton<WsaRoutine> {
	protected:
		friend class Singleton<WsaRoutine>;
		WsaRoutine()
		{
			int res = WSAStartup( MAKEWORD(2,2), &_wsadata );
			if( res != 0 ) {
				throw SocketError( WSAGetLastError() );
			}
		}
	private:
		WSADATA _wsadata;
	};

}

